package com.xs.guess_xingzuo2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    //1.定义对象
    Button btn_search1;
    EditText edit_inputname1;
    DatePicker date_birth1;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //2.绑定控件
        btn_search1 = findViewById(R.id.button_search);
        edit_inputname1 = findViewById(R.id.edit_inputname);
        date_birth1 = findViewById(R.id.datePicker_birth);


        //3.按钮单机事件
        btn_search1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //第一种方法
                Intent intent = new Intent(MainActivity.this,SecondActivity.class);
                intent.putExtra("name",edit_inputname1.getText().toString());
                intent.putExtra("year",date_birth1.getYear());
                intent.putExtra("yue",date_birth1.getMonth());
                intent.putExtra("ri",date_birth1.getDayOfMonth());
                startActivity(intent);
                //第二种方法：
                //按钮单击事件
//                Bundle bundle = new Bundle();
//                bundle.putString("name",edit_inputname1.getText().toString());
//                bundle.putInt("year", date_birth1.getYear();
//                bundle.putString("yue", String.valueOf(date_birth1.getMonth()));
//                bundle.putString("ri", String.valueOf(date_birth1.getDayOfMonth()));
//                intent.putExtra(bundle);
//                startActivity(intent);

            }
        });

    }
}
